package cn.fws.meap.community.web;

import java.util.List;

import cn.fws.meap.community.vo.Details;
import cn.fws.meap.community.vo.InformationListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.fws.meap.community.entity.Information;
import cn.fws.meap.community.service.IInformationService;
import cn.fws.framework.web.contoller.BaseController;
import cn.fws.framework.web.page.PagingResult;
import cn.fws.framework.web.contoller.JsonResponse;

/**
 * 资讯 信息操作处理
 *
 * @author chenkh
 * @date 2019-03-07
 */
@RestController
@RequestMapping("/meap/information")
@Api(tags = "资讯 信息操作处理")
public class InformationController extends BaseController {

    @Autowired
    private IInformationService informationService;

    /**
     * 查询资讯列表
     */
    //@RequiresPermissions("meap:information:list")
    @ApiOperation(value = "查询资讯列表")
    @PostMapping("/list")
    public PagingResult<InformationListVo> list(Information information) {
    	startPage();
        List<InformationListVo> list = informationService.selectList(information);
        return getPagingResult(list);
    }

    /**
     * 查询最新的三条资讯列表
     */
    //@RequiresPermissions("meap:information:list")
    @ApiOperation(value = "查询最新的三条资讯列表")
    @PostMapping("/listNew")
    public List<Details<Information>> selectListNew(Information information) {

        List<Details<Information>> list = informationService.selectListNew();
        return list;
    }

    /**
     * 新增保存资讯
     */
    //@RequiresPermissions("meap:information:add")
    @ApiOperation(value = "新增保存资讯")
    @ApiImplicitParam(name = "information", value = "新增保存资讯", dataType = "Information")
    @PostMapping("/add")
    public JsonResponse addSave(Information information) {
        return toAjax(informationService.insert(information));
    }

    /**
     * 修改保存资讯
     */
    //@RequiresPermissions("meap:information:edit")
    @ApiOperation(value = "修改保存资讯")
    @ApiImplicitParam(name = "information", value = "修改保存资讯", dataType = "Information")
    @PutMapping("/edit")
    public JsonResponse editSave(Information information) {
        return toAjax(informationService.update(information));
    }

    /**
     * 删除资讯
     */
    //@RequiresPermissions("meap:information:remove")
    @ApiOperation(value = "删除资讯")
    @ApiImplicitParam(name = "ids", value = "根据id删除资讯", dataType = "String")
    @DeleteMapping("/remove")
    public JsonResponse remove(String ids) {
        return toAjax(informationService.deleteByIds(ids));
    }

}
